#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# X-SPDX-Copyright-Text: (c) Copyright 2015-2019 Xilinx, Inc.
######################################################################

me=$(basename "$0")
err()  { echo >&2 "$*"; }
log()  { err "$me: $*"; }
fail() { log "FAILED: $*"; exit 1; }
try()  { "$@" || fail "$*"; }

######################################################################
# main()

tgz="$1"
try [ -f "$tgz" ]
dir=${tgz%.tgz}
try tar xf "$tgz"
try [ -d "$dir" ]
try mv "$dir/ChangeLog" "$dir-ChangeLog.txt"
try mv "$dir/ReleaseNotes" "$dir-ReleaseNotes.txt"
try mv "$dir/README" "$dir-README.txt"
try mv "$dir/LICENSES-ALL" "$dir-LICENSES-ALL.txt"
try rm -r "$dir"
